/* ============================================================================
   home.css — 完整样式
   ============================================================================ */

/* ——————————————————————————————————————————————————————————
   1. 主题变量
   —————————————————————————————————————————————————————————— */
:root {
  --gradient-bg: linear-gradient(135deg, #0d1b2a 0%, #1b263b 100%);
  --card-bg: rgba(255,255,255,0.06);
  --sidebar-bg: rgba(255,255,255,0.04);
  --header-bg: rgba(255,255,255,0.06);
  --text: #e0e6f8;
  --accent: #76eefa;
  --shadow: rgba(0,0,0,0.5);
  --header-height: 60px;
  --sidebar-width: 60px;
  --friend-item-height: 70px;
}

/* 全局重置 */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: var(--gradient-bg) fixed; color: var(--text);
  font-family: 'Poppins', sans-serif;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}

/* 主要布局 */
.wrapper, .page-layout { display: flex; height: 100vh; width: 100%; }
.page-main { flex: 1; display: flex; flex-direction: column; }
.container { flex: 1; overflow-y: auto; padding: 1rem; }
.container-inner { max-width: 900px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 1rem; }

/* 侧边栏 */
.sidebar {
  width: 72px; min-width: var(--sidebar-width); height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: 1rem 0; background: var(--sidebar-bg); backdrop-filter: blur(8px);
  box-shadow: 2px 0 12px var(--shadow);
}
.sidebar-top { display: flex; flex-direction: column; gap: 10px; }
.sidebar-btn {
  width: 48px; height: 48px; margin: 0.5rem 0; background: transparent; border: none;
  color: var(--text); font-size: 1.2rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.3s, color 0.3s;
}
.sidebar-btn:hover, .sidebar-btn.active {
  background: var(--accent); color: #0d1b2a; border-radius: 8px;
}

/* 头部 */
.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.5rem; margin: 1rem; background: var(--header-bg);
  backdrop-filter: blur(8px); border-radius: 12px; box-shadow: 0 2px 8px var(--shadow);
}
.header-title { display: flex; align-items: center; gap: 1rem; font-size: 1.25rem; font-weight: 500; }
.header-avatar {
  width: 48px; height: 48px; border-radius: 50%; border: 2px solid var(--accent);
  margin-right: 10px; transition: transform 0.3s, box-shadow 0.3s;
}
.header-avatar:hover { transform: scale(1.1); box-shadow: 0 0 12px var(--accent); }
.btn-ghost {
  background: transparent; border: none; color: var(--text); font-size: 1.2rem; cursor: pointer;
  transition: color 0.3s;
}
.btn-ghost:hover { color: var(--accent); }

/* 面板 */
.panel {
  flex: 1 1 100%; background: var(--card-bg); backdrop-filter: blur(8px);
  border-radius: 12px; padding: 1.5rem; box-shadow: 0 4px 12px var(--shadow);
  transition: transform 0.3s;
}
.panel:hover { transform: translateY(-4px); }
.panel h2 {
  margin: 0 0 1rem 0; color: var(--accent); font-size: 1.5rem;
  border-bottom: 2px solid rgba(118,238,250,0.3); padding-bottom: 0.5rem;
}

/* 好友列表 */
.friend-list { list-style: none; padding: 0; margin: 0; }
.friend-item { margin-top: 0.5rem; cursor: pointer; position: relative; }
.friend-item::after {
  content: ''; position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-size: 12px; color: #999; opacity: 0; transition: opacity 0.3s;
}
.friend-item:hover::after { opacity: 1; }
.friend-card {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px; background: rgba(255,255,255,0.04); border-radius: 8px;
  cursor: pointer; transition: transform 0.3s, box-shadow 0.3s;
}
.friend-card:hover { transform: scale(1.02); box-shadow: 0 4px 12px var(--shadow); }
.friend-info {
  display: flex; align-items: center; gap: 1rem; padding: 15px;
}
.friend-avatar {
  cursor: pointer; transition: transform 0.2s; z-index: 2; position: relative;
}
.friend-avatar:hover { transform: scale(1.1); }
.friend-avatar img {
  width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--accent);
}
.friend-name { font-size: 1rem; color: var(--text); margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.friend-status {
  display: inline-block; width: 10px; height: 10px; margin-left: 8px; border-radius: 50%;
  background: #bbb; vertical-align: middle;
}
.friend-status.online { background: #4caf50; }
.friend-status.offline { background: #bbb; }
.friend-message {
  display: flex; flex-direction: column; align-items: flex-end; max-width: 200px;
}
.last-message {
  color: var(--text); font-size: 0.9em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.message-time { color: #999; font-size: 0.8em; margin-top: 4px; }
.unread-badge {
  position: absolute; top: -5px; right: -5px; background: #ff4444; color: white;
  border-radius: 50%; min-width: 20px; height: 20px; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: bold; box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* 添加好友 */
.add-friend {
  display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem;
}
.add-friend input {
  flex: 1; padding: 0.5rem 0.75rem; border: none; border-radius: 8px;
  background: rgba(255,255,255,0.04); color: var(--text); outline: none; font-size: 1rem;
}
.add-friend button {
  padding: 0.5rem 1rem; background: var(--accent); color: #0d1b2a; border: none; border-radius: 8px;
  cursor: pointer; transition: background 0.3s, transform 0.2s; font-size: 1rem;
}
.add-friend button:hover { background: #4fd4e0; transform: translateY(-2px); }
#addFriendMessage { font-size: 0.9rem; }
#addFriendMessage.success { color: #4caf50; }
#addFriendMessage.error { color: #f44336; }

/* 滚动条美化 */
.container::-webkit-scrollbar { width: 6px; }
.container::-webkit-scrollbar-thumb { background: rgba(118,238,250,0.6); border-radius: 3px; }
.container::-webkit-scrollbar-track { background: transparent; }

/* 天气按钮组 */
.header-actions { display: flex; align-items: center;  gap: 0.5rem; }
.weather-toggle {
  display: flex; flex-direction: column; gap: 6px; padding: 8px 0;
  position: fixed; left: 10px; bottom: env(safe-area-inset-bottom, 10px); z-index: 1000;
}
.weather-toggle button {
  width: 48px; height: 48px; border: none; background: rgba(255, 255, 255, 0.15);
  border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 16px; margin: 0 auto; transition: all 0.3s ease; backdrop-filter: blur(8px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.weather-toggle button:hover, .weather-toggle button:active {
  background: rgba(255, 255, 255, 0.25); transform: scale(1.1);
}
@media screen and (max-height: 600px) {
  .weather-toggle { flex-direction: row; gap: 8px; left: 50%; transform: translateX(-50%); padding: 0 10px; }
}
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .weather-toggle { bottom: calc(env(safe-area-inset-bottom) + 10px); }
}
@media screen and (max-height: 500px) {
  .weather-toggle button { width: 28px; height: 28px; font-size: 14px; }
}

/* 天气容器 */
.weather-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  overflow: hidden;
}

@keyframes fallSnow {
  to {
    transform: translateY(100vh);
    opacity: 0;
  }
}

@keyframes fallRain {
  to {
    transform: translateY(100vh);
    opacity: 0;
  }
}

@keyframes driftCloud {
  from { left: -100px; }
  to   { left: 100vw; }
}

@keyframes pulseSun {
  0%, 100% { transform: scale(2); opacity: 1; }
  50%      { transform: scale(2.4); opacity: 0.8; }
}

/* 雪花/粒子背景/消息气泡/模态框/好友资料 */
.snow-container { display: none; }
#tsparticles.background {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 0;
}
.message-bubble {
  position: fixed; bottom: 20px; right: 20px; background: rgba(0, 0, 0, 0.8); color: white;
  padding: 10px 20px; border-radius: 20px; animation: fadeInOut 3s ease-in-out forwards; z-index: 1000;
}
@keyframes fadeInOut {
  0% { opacity: 0; transform: translateY(20px);}
  10%,90% { opacity: 1; transform: translateY(0);}
  100% { opacity: 0; transform: translateY(-20px);}
}

/* 好友资料模态框 */
.modal-content {
  background: rgba(13, 27, 42, 0.95); backdrop-filter: blur(10px);
  border: 1px solid var(--accent); border-radius: 16px; color: var(--text);
}
.modal-header { border-bottom: 1px solid rgba(118, 238, 250, 0.2); padding: 1.5rem; }
.modal-title { color: var(--accent); font-size: 1.5rem; font-weight: 500; }
.btn-close { color: var(--text); opacity: 0.8; transition: opacity 0.3s; }
.btn-close:hover { opacity: 1; color: var(--accent); }
.modal-body { padding: 2rem; }
.profile-avatar-container { text-align: center; margin-bottom: 2rem; position: relative; }
.profile-avatar {
  width: 120px; height: 120px; border-radius: 50%; border: 3px solid var(--accent);
  box-shadow: 0 0 20px rgba(118, 238, 250, 0.3); transition: transform 0.3s;
}
.profile-avatar:hover { transform: scale(1.05); }
.profile-info-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
.profile-info-item {
  background: rgba(255, 255, 255, 0.05); padding: 1rem; border-radius: 12px; transition: transform 0.3s;
}
.profile-info-item:hover { transform: translateY(-4px); background: rgba(255, 255, 255, 0.08);}
.profile-info-label { color: var(--accent); font-size: 0.9rem; margin-bottom: 0.5rem; display: block; }
.profile-info-value { color: var(--text); font-size: 1.1rem; word-break: break-word; }
.profile-bio {
  grid-column: 1 / -1; background: rgba(255, 255, 255, 0.05);
  padding: 1.5rem; border-radius: 12px; margin-top: 1rem;
}
.profile-bio .profile-info-value { line-height: 1.6; font-style: italic; }
.modal.fade .modal-dialog { transform: scale(0.7); opacity: 0; transition: all 0.3s ease-in-out; }
.modal.show .modal-dialog { transform: scale(1); opacity: 1; }

/* 触摸反馈/移动端适配 */
.friend-item:active { transform: scale(0.98); transition: transform 0.1s; }
.sidebar-btn:active, .add-friend button:active { opacity: 0.7; }
@media screen and (max-width: 768px) {
  .wrapper { height: 100vh; width: 100vw; overflow: hidden; }
  .page-layout { display: flex; height: 100%; }
  .sidebar { width: var(--sidebar-width); }
  .sidebar-btn { width: var(--sidebar-width); height: var(--sidebar-width); font-size: 24px; }
  .page-main { width: calc(100% - var(--sidebar-width)); }
  .header { height: var(--header-height); padding: 0 15px; }
  .header-title { font-size: 18px; }
  .header-avatar { width: 40px; height: 40px; margin-right: 10px; }
  .container { padding: 10px; }
  .friend-item { height: var(--friend-item-height); margin-bottom: 10px; border-radius: 12px; }
  .friend-card { height: 100%; padding: 10px; gap: 12px; }
  .friend-avatar { width: 50px; height: 50px; border-radius: 25px; }
  .friend-name { font-size: 16px; }
  .last-message { font-size: 14px; color: rgba(255, 255, 255, 0.7);}
  .add-friend { padding: 15px; }
  .add-friend input { width: 100%; height: 44px; padding: 0 15px; font-size: 16px; border-radius: 22px; }
  .add-friend button { height: 44px; padding: 0 20px; font-size: 16px; border-radius: 22px; margin-top: 10px; }
  .modal-content { width: 90%; margin: 10vh auto; border-radius: 16px; }
  .modal-body { padding: 20px; }
}